﻿#pragma once
#include "Vector.h"
#include "Config.h"
#include "Transform.h"
#include "Light.h"
#include "Vertex.h"
class Device {
public:
	Device();

	void init(int width, int height, uint32* fb, Transform* ts);
	void clear();
	void close();

	void drawPoint2D(const Vector p, Vector color);
	void drawLine2D(const Vector &v0, const Vector &v1, Vector *color0 = nullptr, Vector *color1 = nullptr);
	void drawLine3D(const Vector &v0, const Vector &v1, Vector *color0 = nullptr, Vector *color1 = nullptr);
	void drawTriangleWireframe(const Vector &v0, const Vector &v1, const Vector &v2);
	void drawTriangleFill(const Vector &v0, const Vector &v1, const Vector &v2);
	void drawTriangleFill(const Vertex &v0, const Vertex &v1, const Vertex &v2);
	Vector PhongSpecularReflection(const Vertex &p);
	Vector blinnPhongSpecularReflection(const Vertex &p);
private:
	//窗口大小
	int width;
	int height;
	//窗口像素
	uint32 ** framebuffer;
	double * zbuffer;//0-1
	Transform* transform;
	int isCheckBack;
	double ambientStrength;
};